﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MaciejGrabek.WP7.Services.Model.Repositories;
using MaciejGrabek.WP7.Services.Model.ViewModel;

namespace MaciejGrabek.WP7.Services.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            IGameResultsRepository repo = new GameResultsRepository();
            var games = repo.GetGames();
            IEnumerable<GameResultsViewModel> model = (from game in games
                                                       select new GameResultsViewModel()
                                                                  {
                                                                      Game = game,
                                                                      Results = repo.GetGameResults(game.NormalizedName)
                                                                  });
            return View(model);
        }
    }
}
